Turbo C Context File MORSE.C VID.C *.CPP C:\CWORK\MORSE\SB.C C:\CWORK\MORSE\MORSE.C C:\CWORK\MORSE\MORSE.H \ for (c=41; c=35) y++; if (y>=24) y=1; for (x=1; x<35; x++) { pokeb(VIDSEG,(x<<1)+(y*160),' '); } x=1; void clrGraph(void) int l, c, col, l160; for (l=0,l160=0; l<(N-1); l++,l160+=160) for (c=41; c>8)&0xFF, ver&0xFF); void clrGraph(void) int l, c, col, l160; for (l=0,l160=0; l<(N-1); l++,l160+=160) for (c=41; c>SCALE)+ (abs(s1Pf31s3f29s5f27s7f25+s2Pf30Ps4f28s6f26Ps8f24)>>SCALE) ) / cntFFT; notSpaceReset = FALSE; totSpace += (bufspace[cntBuf-1] = thisCnt); totMark = cntMark = avgMark = 0; totSpace = cntSpace = avgSpace = 0; notMarkReset = FALSE; notSpaceReset = FALSE; notMarkReset = TRUE; notSpaceReset = FALSE; max ( max ( max(max(avgFFT[ 0],avgFFT[ 1]),max(avgFFT[ 2],avgFFT[ 3])), max(max(avgFFT[ 4],avgFFT[ 5]),max(avgFFT[ 6],avgFFT[ 7])) ), max ( max(max(avgFFT[ 8],avgFFT[ 9]),max(avgFFT[10],avgFFT[11])), max(max(avgFFT[12],avgFFT[14]),avgFFT[14]) ) ) max ( avgFFT[freq], max ( max(avgFFT[freqm2],avgFFT[freqm1]), max(avgFFT[freqp1],avgFFT[freqp2]) ) ) oldallavg = allavg; oldtonedetected = tonedetected; if (avgFFT[ 0]>1); /* interesting frequency */ void FFT2tone(void) { /* determines whether a morse tone is present or not */ static int old3active,old2active=FALSE,old1active=FALSE,active=FALSE; static int average,l,limit,oldtonedetected; average=0; for (l=1 ; l>=LOG2N; limit=FLIP+(5*average); old3active=old2active; old2active=old1active; old1active=active; active=( (fft[freqm2]+fft[freqp2]+fft[freqm1]+fft[freqp1]+fft[freq])>=limit ); oldtonedetected=tonedetected; tonedetected=(active || old1active || old2active || old3active); if (tonedetected && !oldtonedetected) pokeb(videoseg,158,' else if (oldtonedetected && !tonedetected) pokeb(videoseg,158,' avgFFT[freqm1]+ avgFFT[ 0]+ pokeb(VIDSEG, 2482+(target<<1), 0x20); avgFFT[ 0]+ avgFFT[ 1]+ avgFFT[ 2]+ avgFFT[ 3]+ avgFFT[ 4]+ avgFFT[ 5]+ avgFFT[ 6]+ avgFFT[ 7]+ avgFFT[ 8]+ avgFFT[ 9]+ avgFFT[10]+ avgFFT[11]+ avgFFT[12]+ avgFFT[13]+ avgFFT[14] ((morse==MORSE_MORSE)?("morse)."):((morse==MORSE_TEXT)?("text )."):("tone )."))) enum MORSE_TYPES MORSE_MORSE, MORSE_TEXT, MORSE_TONE, MORSE_MAX push ax // save the registers we're using push bx push cx push ds push es push di push si nosound(); freqp1 = freq + 1; pokeb(VIDSEG,(74-160)+(160*freqm2),c1); pokeb(VIDSEG,(74-160)+(160*freqm1),c1); pokeb(VIDSEG,(74-160)+(160*freq),c1); pokeb(VIDSEG,(74-160)+(160*freqp1),c1); pokeb(VIDSEG,(74-160)+(160*freqp2),c1); pokeb(VIDSEG,(76-160)+(160*freqm2),c2); pokeb(VIDSEG,(76-160)+(160*freqm1),c2); pokeb(VIDSEG,(76-160)+(160*freq),c2); pokeb(VIDSEG,(76-160)+(160*freqp1),c2); pokeb(VIDSEG,(76-160)+(160*freqp2),c2); pokeb(VIDSEG,(74-160)+(160*freqm2),c1); pokeb(VIDSEG,(74-160)+(160*freqm1),c1); pokeb(VIDSEG,(74-160)+(160*freq),c1); pokeb(VIDSEG,(74-160)+(160*freqp1),c1); pokeb(VIDSEG,(74-160)+(160*freqp2),c1); pokeb(VIDSEG,(74-160)+(160*outm1), c1); // Clear the audio spectrum analyzer // on the screen. for (l=0,l160=0; l<(N-1); l++,l160+=160) for (c=41; c=35) asm { push ax // save the registers we're using push bx push cx push dx push ds push es push di push si // line to scroll into mov bx, BOXTOP+1 // source and destination segments mov ax, VIDSEG push ax push ax pop ds pop es lineloop: asm { // calculate dest line offset mov ax, 0x00A0 mul bl // calculate the left window inside mov dx, BOXLEF inc dx shl dx, 1 // combine them add ax, dx cmp bx, BOXDIV-1 // see if we're done je scrolldone // leave the scroll if so add ax, 0xA0 // calculate offset of source mov si, ax mov cx, 0x22 // number of WORDS to move rep movsw // move them inc bx // go to the next line jmp lineloop // loop around to calculate it scrolldone: asm { mov ax, 0x0720 // word to clear a display character mov cx, 0x22 // number of words to erase rep stosw pop si // restore the registers we've saved pop di pop es pop ds pop dx pop cx pop bx pop ax x=1; pokeb(VIDSEG,(x<<1)+((BOXDIV-1)*160), c); pokeb(VIDSEG,(x<<1)+((BOXBOT-1)*160), c); if (thisCnt >= (useSpace*3)) { textPutC(0x20); } morsePutC(0x20); morsePutC('-'); morsePutC(0xF9); // Update periodical display stuff. updateDisplay(); // Show new sample rate updateDisplay(); morsePutC(0x20); morsePutC(0x20); morsePutC(0x20); ///////////////////////////////////////////////////////////////////////////// // Add a character to the tone line. void tonePutC(char c) // scroll the tone line (bottom) left // add a character at the end of the line asm { // Save registers push ax push bx push cx push ds push es push di push si // source and destination segments mov ax, VIDSEG push ax push ax pop ds pop es // Dest & source offsets mov di, 0x0F00 mov si, 0x0F02 // Set the move count (words) mov cx, 0x004F // Move the junk rep movsw // Restore registers pop si pop di pop es pop ds pop cx pop bx pop ax pokeb(VIDSEG, (160*25)-2, c); ///////////////////////////////////////////////////////////////////////////// // Put a character into the text window. void textPutC(char c) static int x=BOXLEF+1; pokeb(VIDSEG,(x<<1)+((BOXDIV-1)*160), c); if ((++x)>=BOXRIG) asm { push ax // save the registers we're using push bx push cx push dx push ds push es push di push si // line to scroll into mov bx, BOXTOP+1 // source and destination segments mov ax, VIDSEG push ax push ax pop ds pop es lineloop: asm { // calculate dest line offset mov ax, 0x00A0 mul bl // calculate the left window inside mov dx, BOXLEF inc dx shl dx, 1 // combine them add ax, dx mov di, ax cmp bx, BOXDIV-1 // see if we're done je scrolldone // leave the scroll if so add ax, 0xA0 // calculate offset of source mov si, ax mov cx,(BOXRIG-BOXLEF)-1 rep movsw // move them inc bx // go to the next line jmp lineloop // loop around to calculate it scrolldone: asm { // AX = word to clear; CX = count mov ax, 0x0720 mov cx, (BOXRIG-BOXLEF)-1 rep stosw // clear the last line in the window pop si // restore the registers we've saved pop di pop es pop ds pop dx pop cx pop bx pop ax x=BOXLEF+1; ///////////////////////////////////////////////////////////////////////////// // Put a character into the morse window. void morsePutC(char c) static int x=BOXLEF+1; pokeb(VIDSEG,(x<<1)+((BOXBOT-1)*160), c); if ((++x)>=BOXRIG) asm { push ax // save the registers we're using push bx push cx push dx push ds push es push di push si // line to scroll into mov bx, BOXDIV+1 // source and destination segments mov ax, VIDSEG push ax push ax pop ds pop es lineloop: asm { // calculate dest line offset mov ax, 0x00A0 mul bl // calculate the left window inside mov dx, BOXLEF inc dx shl dx, 1 // combine them add ax, dx mov di, ax cmp bx, BOXBOT-1 // see if we're done je scrolldone // leave the scroll if so add ax, 0xA0 // calculate offset of source mov si, ax // word count to move mov cx, (BOXRIG-BOXLEF)-1 rep movsw // move them inc bx // go to the next line jmp lineloop // loop around to calculate it scrolldone: asm { // AX = clear word; CX = word count mov ax, 0x0720 mov cx, (BOXRIG-BOXLEF)-1 rep stosw pop si // restore the registers we've saved pop di pop es pop ds pop dx pop cx pop bx pop ax x=(BOXLEF+1); pokeb(VIDSEG, 158, 0xEC); // Display a character in the "tone" display across the screen bottom. void tonePutC(char c) // scroll the tone line (bottom) left // add a character at the end of the line asm { // Save registers push ax push bx push cx push ds push es push di push si // source and destination segments mov ax, VIDSEG push ax push ax pop ds pop es // Dest & source offsets mov di, 0x0F00 mov si, 0x0F02 // Set the move count (words) mov cx, 0x004F // Move the junk rep movsw // Restore registers pop si pop di pop es pop ds pop cx pop bx pop ax pokeb(VIDSEG, (160*25)-2, c); if (useSpace>1) { useSpace--; updateDisplay(); } break; if (useSpace>100) { useSpace -= 100; updateDisplay(); } break; if (useSpace<2000) { useSpace++; updateDisplay(); } break; if (useSpace<9999) { useSpace++; updateDisplay(); } break; if (thrNoise>1) { thrNoise--; updateDisplay(); } break; if (thrNoise<9999) { thrNoise++; updateDisplay(); } break; if (useMark>1) { useMark--; updateDisplay(); } break; if (useMark<9999) { useMark++; updateDisplay(); } break; f[k]=(*(dsp+=waitfactor))-128; f[k]=(*(dsp+=waitfactor))-128; f[ k]=(*(dsp+=waitfactor))-128; memmove(bufSpace, bufSpace+1, cntBuf-1); avgSpace = (totSpace += (bufSpace[cntBuf-1] = thisCnt))/cntBuf;